﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CodeDynamiksEngine;
using MESCodeFile;

namespace mes_tublay
{
    public partial class frmTeamSampler : Form
    {
        public frmTeamSampler()
        {
            InitializeComponent();
            InitializeFrameSliderForm();
        }
        private void InitializeForm()
        {
            ConcatSample();
        }
        void ConcatSample()
        {
            CodeScript s = new CodeScript("CONCAT");
            s.Add(CodeIns.DBU_NEW_CORE);
            s.Add(CodeIns.DBU_CONNECT, Common.CFG.Read("DRIVER"), Common.CFG.Read("DB"),
                        Common.CFG.Read("UID"), Common.CFG.Read("PWD"), Common.CFG.Read("SERVER"));

            s.Add(CodeIns.DBU_QUERY, "SELECT concat(fUID,',',fPCount) AS fconcatresult FROM tblusers ORDER BY fUID ASC");
            s.Add(CodeIns.DBU_END);

            CodeProcessor p = new CodeProcessor(ThreadingMode.Normal);
            p.ProcessCompleted += new EventHandler(delegate
            {
                p.SafeCall(this, delegate
                {
                    if (p.State == ProcessorFlag.DataRdyErr ||
                        p.State == ProcessorFlag.Error ||
                        p.State == ProcessorFlag.ReadyErr)
                    {
                        Confirm.Error("Sampler", p.GetProcessorMessage);
                        return;
                    }
                    DataCache d;
                    p.DataFetch(out d);
                    d.SetActivePage(0);
                    textBox1.Text = d.GetValue(0,"fconcatresult").ToString();
                });
            });
            p.Run(s);
        }
    }
}
